﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using Vhcs.Data.Shared;

namespace Vhcs.Data.Dao
{
    class PeopleDao
    {
        public string GetReportingLine(string empID)
        {
            //throw new NotImplementedException();
            string storeName = @"K2_spGetManager";
            object[] parms = { "@EmpID", empID };

            return Db.ReadFromStore(storeName, MakeReportingLine, parms);
        }

        public string GetDeptHead(string empID)
        {
            string storeName = @"K2_spGetManager";
            object[] parms = { "@EmpID", empID };

            return Db.ReadFromStore(storeName, MakeDeptHead, parms);
        }

        public string GetHrbpLeader(string empID)
        {
            string storeName = @"K2_spGetManager";
            object[] parms = { "@EmpID", empID };

            string lst_hrbp= Db.ReadFromStore(storeName, MakeHrbpLeader, parms);
            return (lst_hrbp.Split(','))[0];
        }

        public string GetHrbpAssistant(string empID)
        {
            string storeName = @"K2_spGetManager";
            object[] parms = { "@EmpID", empID };

            string lst_hrbp = Db.ReadFromStore(storeName, MakeHrbpAssistant, parms);
            return (lst_hrbp.Split(','))[0];
        }

        public string GetHrDeptHead(string empID)
        {
            throw new NotImplementedException();
        }



        private Func<IDataReader, string> MakeReportingLine = reader =>
            reader["ReportingLine"].AsString();

        private Func<IDataReader, string> MakeDeptHead = reader =>
            reader["DeptHead"].AsString();

        private Func<IDataReader, string> MakeHrbpLeader = reader =>
            reader["HrbpLeader"].AsString();

        private Func<IDataReader, string> MakeHrbpAssistant = reader =>
            reader["HrbpAssitant"].AsString();
    }
}
